package com.huixh.train.business.controller.admin;

import com.huixh.train.business.req.DailyTrainStationQueryReq;
import com.huixh.train.business.req.DailyTrainStationSaveReq;
import com.huixh.train.business.resp.DailyTrainStationQueryResp;
import com.huixh.train.business.service.DailyTrainStationService;
import com.huixh.train.common.resp.PageResult;
import com.huixh.train.common.resp.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
* @author huixh
*/
@Tag(name = "每日车次站点信心")
@Validated
@RestController
@RequestMapping("/admin/dailyTrainStation")
public class DailyTrainStationController {
    @Resource
    private DailyTrainStationService dailyTrainStationService;

    @PostMapping("/save")
    @Operation(summary = "保存/编辑")
    public Result<?> save(@RequestBody @Valid DailyTrainStationSaveReq dailyTrainStationSaveReq) {
    dailyTrainStationService.save(dailyTrainStationSaveReq);
        return Result.success();
    }

    @PostMapping("/quest-list")
    @Operation(summary = "查询列表")
    public PageResult<List<DailyTrainStationQueryResp>> query(@RequestBody @Valid DailyTrainStationQueryReq dailyTrainStationQueryReq) {
        return dailyTrainStationService.queryList(dailyTrainStationQueryReq);
    }

    @DeleteMapping("/delete/{id}")
    @Operation(summary = "删除")
    public Result<?> deleteById(@NotNull @PathVariable(name = "id") Long id) {
        dailyTrainStationService.delete(id);
        return Result.success("删除成功");
    }
}